<template>
	<!-- 提交订单 -->
	<view style="height: auto;">
		<view class="dc_order">
			<view class="zuohao_num flex-cb">
				<text class="num">桌号：<text>{{goods.table_name}}</text></text>
				<text class="state" :class="{state1:1}">
				{{goods.status==0?'待支付':goods.status==1?'待店家处理':goods.status==3?'已完成(待评价)':goods.status==6?'店家已处理':goods.status==7?'已评价':'已取消'}}</text>
			</view>
			<view class="min flex justify-between" v-for="i in goods.goods" :key="i">
				<image :src="url+i.main_image" mode=""></image>
				<view class="text_div">
					<view class="span">{{i.title}} {{i.spec_item_name}}</view>
					<view class="flex-cb jifen">
						<text>x{{i.number}}</text>
						<text class="jifen100">积分最多抵扣￥{{i.point_price||0}}</text>
					</view>
				</view>
			</view>
			<view class="solid"></view>
			<view class="vipPrice flex align-center justify-end">
				<text>会员价</text>
				<view>￥{{goods.vip_amount}}</view>
				<text>原价</text>
				<view>￥{{goods.amount}}</view>
			</view>
		</view>
		<view class="beizhu">
			<text>备注</text>
			<textarea :value="goods.remark" disabled />
		</view>
		<view class="foot">
			<text class="order">订单信息</text>
			<view class="solid"></view>
			<view class="order_num flex-cb">
				<text>订单编号</text>
				<text>{{goods.order_no}}</text>
			</view>
			<view class="order_num flex-cb">
				<text>下单时间</text>
				<text>{{goods.updated_at}}</text>
			</view>
			<view class="order_num flex-cb" v-if="goods.pay_time">
				<text>支付时间</text>
				<text>{{goods.pay_time}}</text>
			</view>
			<!-- <view class="order_num flex-cb" v-if="goods.pay_time">
				<text>完成时间</text>
				<text>{{goods.pay_time}}</text>
			</view> -->
		</view>
		<scroll-view scroll-x="true" class="bottom bg-white" enable-flex >
			<view class="flex  align-center justify-end" :style="{paddingBottom:iphone/2 + 'rpx'}">
				<view class="button"  v-if="goods.status == 0" @click="handleQx">取消订单</view>
				<view  class="button button1" v-if="goods.status == 0" @click="qery(goods_id)">立即付款</view>
				<view  class="button button1" v-if="goods.status == 3" @click="evaluate">去评价</view>
				<!-- <view class="button button2" >删除订单</view> url="../Function list/vipPayment"-->
				
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url:'',
				iphone:'',
				goods:'',
				goods_id:''
			};
		},
		onLoad(e) {
			this.url = this.$base
			this.goods_id = e.id
			this.getgoods(this.goods_id)
			this.iphone = getApp().globalData.iphone
		},
		methods:{
			getgoods(id){
				this.$api.self_pick_list_details({},id,1).then(res=>{
					console.log(res);
					this.goods = res.data
					this.codeurl += res.data.id
					for (let i = 0; i < res.data.goods.length; i++) {
						this.num += this.goods.goods[i].number
					}
				})
			},
			evaluate(){//评价
				uni.navigateTo({
					url:"./refund/refund?tuikuan=0&zt=1"+'&id='+this.goods_id
				})
			},
			handleQx(){
				this.$api.self_pick_cancel({},this.goods_id,1).then(res=>{
					if(res.code == 200001){
						this.getgoods(this.goods_id)
					}
				})
			},
			qery(id){
				this.$api.merchant_pay({},id,1).then(res=>{
					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: res.data.timeStamp,
						nonceStr: res.data.nonceStr,
						package: res.data.package,
						signType: res.data.signType,
						paySign: res.data.paySign,
						// orderInfo:res.data.prepay_id,
						 success:(r)=>{  
							 console.log(r,3);
							 this.$api.merchant_pay_notify({},id,1).then(res=>{
							 	console.log(res,'4');
							 	 if(res.code == 200001){
									 uni.showToast({
									 	title:"支付成功",icon:"none"
									 })
							 		 this.getgoods(id)
							 	 }
							 })
						 }, 
						 fail(err) {
						 	console.log(err);
						 }
					})
				})
			}
		}
	}
</script>

<style lang="scss">
.dc_order{
	width: 710rpx;
	height: auto;
	background: #FFFFFF;
	border-radius: 20rpx;
	margin: auto;
	margin-top: 10rpx;
	.zuohao_num{
		padding: 32rpx 17rpx 0 36rpx;
		font-weight: bold;
		.num{
			font-size: 26rpx;
			text{
				font-size: 32rpx;
			}
		}
		.state{
			color: #CCC;
			font-size: 34rpx;
		}
		.state1{
			color: #1CD699;
		}
	}
	.min{
		padding: 11rpx 24rpx 20rpx 38rpx;
		image{
			width: 176rpx;height: 176rpx;
		}
		.text_div{
			margin-left: 22rpx;
			.span{
				width: 448rpx;
				height: 90rpx;
				margin-top: 10rpx;
				font-size: 28rpx;
				line-height: 50rpx;
				font-weight: bold;
				color: #252525;
			}
			.jifen{
				margin-top: 22rpx;
				font-size: 34rpx;
				
				.jifen100{
					color: #FF6F10;
					font-size: 24rpx;
				}
			}
		}
	}
	.solid{
		width: 686rpx;
		margin: auto;
	}
	.vipPrice{
		padding-right: 24rpx;
		height: 112rpx;
		font-weight: bold;
		text{
			margin-left: 10rpx;
			font-size: 30rpx;
		}
		view{
			margin-left: 10rpx;
			font-size: 40rpx;
		}
	}
}
.beizhu,.foot{
	width: 710rpx;
	height: 265rpx;
	background: #FFFFFF;
	border-radius: 20rpx;
	margin:10rpx auto ;
	padding: 28rpx 30rpx;
	font-weight: bold;
	overflow: hidden;
	text{
		font-size: 30rpx;
		color: #252525;
	}
	textarea{
		height: 100%;
		padding-top: 25rpx;
		font-size: 26rpx;
	}
}
.foot{
	padding: 20rpx 0 0 0;
	margin-bottom: 180rpx;
	height: auto;
	.order{
		margin-left: 28rpx;
	}
	.solid{
		width: 690rpx;
		margin: 28rpx auto;
	}
	.order_num{
		padding:20rpx 28rpx;
		font-size: 30rpx;
		text{
			color: #666666;
		}
	}
}
.bottom{
	min-height: 107rpx;
	padding: 17rpx 30rpx 20rpx 0;
	position: fixed;
	bottom: 0;
	left: 0;
	white-space: nowrap;
	.button{
		width: 210rpx;
		height: 70rpx;
		margin-left: 12rpx;
		border-radius: 70rpx;
		font-size: 30rpx;
		line-height: 70rpx;
		text-align: center;
		color: #999999;
		border: 2px solid #B8B8B8;
	}
	.button1{
		background: #1CD699;
		color: #fff;
		border: none;
	}
	.button2{
		background:#FF2E2E ;
		color: #fff;
		border: none;
	}
}
</style>
